package cn.nfwx.tv.fragment.dialog;

import android.os.Bundle;
import android.view.View;

import cn.nfwx.tv.R;
import cn.nfwx.tv.base.BaseDialogFragment;

/**
 * Created by dell on 2018/4/20.
 */

public class QuitAppDialogFragment extends BaseDialogFragment implements View.OnClickListener {

    onQuitListener onQuitListener;

    public interface onQuitListener {
        void quitSure();
    }

    public void setOnQuitListener(QuitAppDialogFragment.onQuitListener onQuitListener) {
        this.onQuitListener = onQuitListener;
    }

    public static QuitAppDialogFragment newInstance() {
        QuitAppDialogFragment fragment = new QuitAppDialogFragment();
        return fragment;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_quit;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        findView(R.id.ll_quit).setOnClickListener(this);
        findView(R.id.quit_sure).setOnClickListener(this);
        findView(R.id.quit_cancel).setOnClickListener(this);
    }

    @Override
    protected boolean isMatchParent() {
        return true;
    }

    @Override
    protected boolean isTranslucentBackground() {
        return true;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ll_quit:
            case R.id.quit_cancel:
                dismiss();
                break;
            case R.id.quit_sure:
                if(onQuitListener != null){
                    onQuitListener.quitSure();
                }
                break;
        }
    }
}
